import { createSlice } from '@reduxjs/toolkit'
const counterStore = createSlice({
    name: 'counter',
    // 初始化state
    initialState: {
        count: 0,
    },
    // 修改状态
    reducers: {
        increment(state) {
            state.count++
        },
        decrement(state) {
            state.count--
        },
        addNum(state, action) {
            state.count += action.payload
        },
    },
})

const { increment, decrement, addNum } = counterStore.actions
const reducer = counterStore.reducer

export { increment, decrement, addNum }
export default reducer
